<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.ReadDAO"%>
<%@page import="db.Read"%>
<%@page import="org.json.JSONObject"%>
<%
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	ReadDAO readDao = (ReadDAO)ctx.getBean("ReadDAO");

	int uid = (Integer)session.getAttribute("id");

	String idPar = request.getParameter("id");
	int id = 0;

	try{
		id = Integer.parseInt(idPar);
	}catch(Exception e){
		id = 0;
	}

	Read read = readDao.findById(id);
	read.setIsRead(1);
	readDao.attachDirty(read);
	
	JSONObject json = new JSONObject();
	out.print(json.toString());
%>